<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" value="frank" abc="tom" autofocus><a href="javascript:void(0)" id="forP">隐藏</a>
<script>
    console.log(document.getElementsByTagName('input')[0].value)
    console.log(document.getElementsByTagName('input')[0].getAttribute('value'))
    console.log(document.getElementsByTagName('input')[0].getAttribute('type'))
    console.log(document.getElementsByTagName('input')[0].getAttribute('abc'))
    console.log(document.getElementsByTagName('input')[0].getAttribute('autofocus'))
    console.log(document.getElementsByTagName('input')[0].autofocus);//简写书写使用点的方式读取

    var inputObj = document.getElementsByTagName('input')[0];
   // inputObj.setAttribute('type','password')
    var forPObj = document.getElementById('forP');
    forPObj.onclick = function () {
        //在这个函数内部 this === forPObj
        if (this.innerHTML == '隐藏'){
            inputObj.setAttribute('type','password')
            this.innerHTML = '显示'
        } else  {
            inputObj.setAttribute('type','text')
            this.innerHTML = '隐藏'
        }

    }
</script>
</body>
</html>